package com.sgb.jicai.entity;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;
import com.swgk.core.util.TimeUtil;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * 加盟集采  页面详情实体类
 * 二次加盟时复用页面，复用该实体类
 */
public class JoinJicaiDetailEntity implements Serializable {
    @SerializedName("createCompany")
    private String createCompany;//加盟方
    //省
    @SerializedName(value = "receiptProvinceNo", alternate = {"offerAreaProvinceNo"})
    private String receiptProvinceNo;
    @SerializedName("receiptProvinceName")
    private String receiptProvinceName;
    //市
    @SerializedName("receiptCityNo")
    private String receiptCityNo;
    @SerializedName("receiptCityName")
    private String receiptCityName;
    //区
    private String receiptDistrictNo;//收货地区级编号
    private String receiptDistrictName;//收货地区级名称
    //详细地址
    @SerializedName(value = "detailsAddress", alternate = "receiptAddress")
    private String detailsAddress;
    //联系人
    @SerializedName("contacts")
    private String contacts;
    //联系人电话
    @SerializedName("contactNumber")
    private String contactNumber;
    //负责人
    @SerializedName("director")
    private String director;
    //负责人电话
    @SerializedName("directorNumber")
    private String directorNumber;
    //联系邮箱
    @SerializedName("email")
    private String email;
    //备注
    @SerializedName("remarks")
    private String remarks;
    @SerializedName(value = "groupbuyingRecordDetailList", alternate = {"details"})
    private ArrayList<RecordDetailListEntity> groupbuyingRecordDetailList;
    @SerializedName("customerServiceContactsId")
    private String customerServiceContactsId;//发起交流
    //限定截止时间---
    @SerializedName("deadline")
    private String deadline;
    //附件地址
    @SerializedName("file")
    private String file;
    private String groupbuyClass;

    public String getGroupbuyClass() {
        return groupbuyClass;
    }

    public void setGroupbuyClass(String groupbuyClass) {
        this.groupbuyClass = groupbuyClass;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    private String id;

    public String getCreateCompany() {
        return createCompany;
    }

    public void setCreateCompany(String createCompany) {
        this.createCompany = createCompany;
    }

    public String getReceiptProvinceNo() {
        return receiptProvinceNo;
    }

    public void setReceiptProvinceNo(String receiptProvinceNo) {
        this.receiptProvinceNo = receiptProvinceNo;
    }

    public String getReceiptProvinceName() {
        return receiptProvinceName;
    }

    public void setReceiptProvinceName(String receiptProvinceName) {
        this.receiptProvinceName = receiptProvinceName;
    }

    public String getReceiptCityNo() {
        return receiptCityNo;
    }

    public void setReceiptCityNo(String receiptCityNo) {
        this.receiptCityNo = receiptCityNo;
    }

    public String getReceiptCityName() {
        return receiptCityName;
    }

    public void setReceiptCityName(String receiptCityName) {
        this.receiptCityName = receiptCityName;
    }

    public String getReceiptDistrictNo() {
        return receiptDistrictNo;
    }

    public void setReceiptDistrictNo(String receiptDistrictNo) {
        this.receiptDistrictNo = receiptDistrictNo;
    }

    public String getReceiptDistrictName() {
        return receiptDistrictName;
    }

    public void setReceiptDistrictName(String receiptDistrictName) {
        this.receiptDistrictName = receiptDistrictName;
    }

    public String getDetailsAddress() {
        return detailsAddress;
    }

    public void setDetailsAddress(String detailsAddress) {
        this.detailsAddress = detailsAddress;
    }

    public String getContacts() {
        return contacts;
    }

    public void setContacts(String contacts) {
        this.contacts = contacts;
    }

    public String getContactNumber() {
        return contactNumber;
    }

    public void setContactNumber(String contactNumber) {
        this.contactNumber = contactNumber;
    }

    public String getDirector() {
        return director;
    }

    public void setDirector(String director) {
        this.director = director;
    }

    public String getDirectorNumber() {
        return directorNumber;
    }

    public void setDirectorNumber(String directorNumber) {
        this.directorNumber = directorNumber;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public ArrayList<RecordDetailListEntity> getGroupbuyingRecordDetailList() {
        return groupbuyingRecordDetailList;
    }

    public void setGroupbuyingRecordDetailList(ArrayList<RecordDetailListEntity> groupbuyingRecordDetailList) {
        this.groupbuyingRecordDetailList = groupbuyingRecordDetailList;
    }

    public String getCustomerServiceContactsId() {
        return customerServiceContactsId;
    }

    public void setCustomerServiceContactsId(String customerServiceContactsId) {
        this.customerServiceContactsId = customerServiceContactsId;
    }

    public String getDeadline() {
        return deadline;
    }

    public void setDeadline(String deadline) {
        this.deadline = deadline;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public class RecordDetailListEntity {
        @SerializedName("detailNo")
        private String detailNo;// 提交加盟时需要的 物料no-- groupbuyingDetailNo
        @SerializedName("attrlist")
        private ArrayList<AttrlistEntity> attrlist;
        @SerializedName("goodsName")
        private String goodsName;//商品名称
        @SerializedName("rangeBrands")
        private String rangeBrands;//品牌范围
        @SerializedName("unitName")
        private String unitName;//计量单位
        @SerializedName("goodsDescribe")
        private String goodsDescribe;//特征描述
        @SerializedName("count")
        private String count;//当前采购量
        @SerializedName("groupbuyClass")
        private int groupbuyClass;//  1 为商品，非1为其它
        /**
         * 首次加盟时 下面字段不从接口获取，用户输入或拼接
         * 修改加盟信息时需要先获取
         */
        @Deprecated
        @SerializedName("expectPrice")
        private String expectPrice;//预期价格  V1。17 删除
        @SerializedName("num")
        private String ownNum;//采购量 num
        @SerializedName("pickTime")
        private String pickTime;//提货时间---商品使用
        @SerializedName("entranceTime")
        private String entranceTime;//入场时间---非商品时使用此
        @SerializedName("exitTime")
        private String exitTime;  // 退厂时间--
        //商品参数---使用attrlist拼接
        private String goodsParameters;//商品参数

        private String participantId;//没有被加盟过时为0

        private String id;
        private String goodsMaterial;
        private String goodsQuality;
        private String goodsMaintenance;
        private String goodsPurpose;

        public String getGoodsMaterial() {
            if (!TextUtils.isEmpty(goodsMaterial)){
                return goodsMaterial;
            }else {
                return "/";
            }
        }

        public void setGoodsMaterial(String goodsMaterial) {
            this.goodsMaterial = goodsMaterial;
        }

        public String getGoodsQuality() {
            if (!TextUtils.isEmpty(goodsQuality)){
                return goodsQuality;
            }else {
                return "/";
            }
        }

        public void setGoodsQuality(String goodsQuality) {
            this.goodsQuality = goodsQuality;
        }

        public String getGoodsMaintenance() {
            if (!TextUtils.isEmpty(goodsMaintenance)){
                return goodsMaintenance;
            }else {
                return "/";
            }
        }

        public void setGoodsMaintenance(String goodsMaintenance) {
            this.goodsMaintenance = goodsMaintenance;
        }

        public String getGoodsPurpose() {
            if (!TextUtils.isEmpty(goodsPurpose)){
                return goodsPurpose;
            }else {
                return "/";
            }
        }

        public void setGoodsPurpose(String goodsPurpose) {
            this.goodsPurpose = goodsPurpose;
        }

        public String getDetailNo() {
            return detailNo;
        }

        public void setDetailNo(String detailNo) {
            this.detailNo = detailNo;
        }

        public ArrayList<AttrlistEntity> getAttrlist() {
            return attrlist;
        }

        public void setAttrlist(ArrayList<AttrlistEntity> attrlist) {
            this.attrlist = attrlist;
        }

        public String getGoodsName() {
            return goodsName;
        }

        public void setGoodsName(String goodsName) {
            this.goodsName = goodsName;
        }

        public String getRangeBrands() {
            return rangeBrands;
        }

        public void setRangeBrands(String rangeBrands) {
            this.rangeBrands = rangeBrands;
        }

        public String getUnitName() {
            return unitName;
        }

        public void setUnitName(String unitName) {
            this.unitName = unitName;
        }

        public String getGoodsDescribe() {
            return goodsDescribe;
        }

        public void setGoodsDescribe(String goodsDescribe) {
            this.goodsDescribe = goodsDescribe;
        }

        public String getCount() {
            return count;
        }

        public void setCount(String count) {
            this.count = count;
        }

        public int getGroupbuyClass() {
            return groupbuyClass;
        }

        public void setGroupbuyClass(int groupbuyClass) {
            this.groupbuyClass = groupbuyClass;
        }

        @Deprecated   //V1。17 过期
        public String getExpectPrice() {
            return expectPrice;
        }

        @Deprecated  //V1。17 过期
        public void setExpectPrice(String expectPrice) {
            this.expectPrice = expectPrice;
        }

        public String getOwnNum() {
            return ownNum;
        }

        public void setOwnNum(String ownNum) {
            this.ownNum = ownNum;
        }

        public String getPickTime() {
            if (null != pickTime && pickTime.length() > 0 && !pickTime.equals("0")) {
                return TimeUtil.getDateStringYMD(Long.valueOf(pickTime));
            } else {
                return "";
            }
//            return pickTime;
        }

        public String getPickTime2() {
           /* if (null != pickTime && pickTime.length() > 0 && !pickTime.equals("0")) {
                try {
                    return String.valueOf(TimeUtil.getLongTime(pickTime, "yyyy-MM-dd"));
                } catch (ParseException e) {
                    e.printStackTrace();
                    return "";
                }
            } else {
                return "";
            }*/
            return pickTime;
        }

        public void setPickTime(String pickTime) {
            this.pickTime = pickTime;
        }

        public String getEntranceTime() {
            if (null != entranceTime && entranceTime.length() > 0 && !entranceTime.equals("0")) {
                return TimeUtil.getDateStringYMD(Long.valueOf(entranceTime));
            } else {
                return "";
            }
//            return entranceTime;
        }

        public void setEntranceTime(String entranceTime) {
            this.entranceTime = entranceTime;
        }

        public String getExitTime() {
            if (null != exitTime && exitTime.length() > 0 && !exitTime.equals("0")) {
                return TimeUtil.getDateStringYMD(Long.valueOf(exitTime));
            } else {
                return "";
            }
//            return exitTime;
        }

        public void setExitTime(String exitTime) {
            this.exitTime = exitTime;
        }

        public String getGoodsParameters() {
            if (getAttrlist()!=null&&getAttrlist().size()>0){
                StringBuffer str = new StringBuffer();
                for (AttrlistEntity attrlistEntity : getAttrlist()) {
                    if (!TextUtils.isEmpty(attrlistEntity.getValue())){
                        str.append(attrlistEntity.getName()).append(":").append(attrlistEntity.getValue()).append("   ");
                    }
                }
                if (!TextUtils.isEmpty(str.toString())){
                    return new String(str);
                }else {
                    return "无";
                }
            }else {
                return "无";
            }
            /*ArrayList<AttrlistEntity> parameters = getAttrlist();
            if (null != parameters && !parameters.isEmpty()) {
                StringBuffer str = new StringBuffer();
                for (int index = 0; index < parameters.size(); index++) {
                    str.append(parameters.get(index).getName()).append(":").append(parameters.get(index).getValue()).append("   ");
                }
                return new String(str);
            } else {
                return " ";
            }*/
        }

        public void setGoodsParameters(String goodsParameters) {
            this.goodsParameters = goodsParameters;
        }

        public String getParticipantId() {
            return participantId;
        }

        public void setParticipantId(String participantId) {
            this.participantId = participantId;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }

    public class AttrlistEntity {
        @SerializedName("name")
        private String name;
        @SerializedName("value")
        private String value;
        //其它未使用字段暂未定义

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }

}
